const path = require('path')
const productModel = require(path.join(__dirname,"../model/productModel.js"))
const homeModel = require(path.join(__dirname,"../model/homeModel.js"))

/**
 * 获取商品详情页面
 */
exports.index = (req,res) => {
    const goodsId = req.params.goodsId || ''

    Promise.all([
        productModel.getProduct(goodsId),
        homeModel.getLikes()
    ]).then(results=>{
        res.locals.detail = results[0]
        res.locals.likes = results[1]

        res.render(path.join(__dirname,"../views/item"))
    })
}